package com.hydra.file.feign;

import com.hydra.base.resp.Response;
import feign.Param;
import lombok.Data;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 文件服务类的第三方远程调用接口
 * 注意，FeignClient注解的url加个冒号是为了允许读取的配置不存在时赋空值
 */
@Component
@FeignClient(
		value="${feign.service.file-service.name}",
		url="${feign.service.file-service.url:}"
)
public interface FeignFileService {

	@PostMapping(value="/api/file/downloadImage")
	Response downloadImage(@RequestBody downloadImage.Input input);

	/**检查图片是否存在*/
	@RequestMapping("/api/file/checkAndDelete")
	Response checkAndDelete(@RequestBody checkAndDelete.Input input);

	@RequestMapping("/api/file/deleteFile")
	Response deleteFile(Long id);

	/**检查图片是否存在*/
	interface checkAndDelete{
		@Data
		class Input{
			Long id;
			boolean delete;
			String movePath;
			String remark;
		}
	}

	/**下载图片*/
	interface downloadImage{
		@Data
		class Input{
			/**下载路径*/
			String url;
			/**文件名称*/
			String fileName;
			/**文件后缀*/
			String fileSuffix;
			/**文件保存路径*/
			String filePath;
			/**备注*/
			String remark;
		}
	}

}
